﻿@using System.Collections.Generic
@using Microsoft.Azure.IoTSuite.Connectedfactory.WebApp.Security
@using GlobalResources
@using Microsoft.Azure.IoTSuite.Connectedfactory.WebApp.Navigation

@model List<Microsoft.Azure.IoTSuite.Connectedfactory.WebApp.Navigation.NavigationMenuItem>
    <nav class="navigation">
        @foreach (var navigationMenuItem in Model)
        {
            var multipleClasses = "navigation_link " + navigationMenuItem.Class;

            if (navigationMenuItem.Class == "navigation_link_hamburger")
            {
                <a id="hamburger" aria-label="@navigationMenuItem.AriaLabel" class="navigation_link @navigationMenuItem.Class" href="#"></a>
            }
            else if (navigationMenuItem.Class == "navigation_link_contoso")
            {
                <div aria-label="@navigationMenuItem.AriaLabel" class="navigation_link @navigationMenuItem.Class">@navigationMenuItem.Text</div>
            }
            else
            {
                @Html.ActionLink(navigationMenuItem.Text, navigationMenuItem.Action, navigationMenuItem.Controller, null, new { @class = multipleClasses, @aria_label = navigationMenuItem.AriaLabel })
            }
        }
    </nav>

@foreach (var navigationMenuItem in Model.Where(navigationMenuItem => navigationMenuItem.Selected && navigationMenuItem.Children != null))
{
    <nav class="navigation">
        @foreach (var childNavigationItem in navigationMenuItem.Children)
        {
            RouteValueDictionary valueDictionary = null;
            if (childNavigationItem.Selected)
            {
                <a aria-label="@navigationMenuItem.AriaLabel" class="@childNavigationItem.Class">@childNavigationItem.Text</a>
            }
            else
            {
                if (childNavigationItem.Controller.Equals("Dashboard", StringComparison.OrdinalIgnoreCase) && childNavigationItem.Action.Equals("Index", StringComparison.OrdinalIgnoreCase))
                {
                    valueDictionary = new RouteValueDictionary { { "topNode", "" } };
                }
            }
            @Html.ActionLink(childNavigationItem.Text, childNavigationItem.Action, childNavigationItem.Controller, valueDictionary, new { @class = childNavigationItem.Class, @aria_label = navigationMenuItem.AriaLabel })
        }
    </nav>
}